package com.vf.admin.common;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dypnsapi.model.v20170525.GetMobileRequest;
import com.aliyuncs.dypnsapi.model.v20170525.GetMobileResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.google.gson.Gson;

public class GetMobileUtils {

    public static GetMobileResponse get(String accessToken) {

        // 初始化acsClient,暂不支持region化
        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI5tLRaaRm8XhkNZj1kSgq",
                "RBPqGhSkEHMdyDVqelryXezJRQHiWn");

        IAcsClient client = new DefaultAcsClient(profile);

        GetMobileResponse response = null;
        GetMobileRequest request = new GetMobileRequest();
        request.setRegionId("cn-hangzhou");
        request.setAccessToken(accessToken);
        request.setEndpoint("dypnsapi.aliyuncs.com");

        try {
            response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
        return response;
    }

}
